home *** CD-ROM | disk | FTP | other *** search
- Path: newshost.lanl.gov!tanmoy
- From: tanmoy@qcd.lanl.gov (Tanmoy Bhattacharya)
- Newsgroups: comp.lang.ada,comp.lang.c
- Subject: Re: C/C++ knocks the crap out of Ada
- Date: 04 Mar 1996 22:53:15 GMT
- Organization: Los Alamos National Laboratory
- Distribution: world
- Message-ID: <TANMOY.96Mar4155315@qcd.lanl.gov>
- References: <JSA.96Feb16135027@organon.com> <4gaa6l$8mk@post.gsfc.nasa.gov>
- <4gd94r$isu@mack.rt66.com> <1996Feb22.005518.13396@leeweyr.sccsi.com>
- <4gvrffINNlqo@anvil.ugrad.cs.ubc.ca>
- <4h4j31$1ga3@watnews1.watson.ibm.com>
- <TANMOY.96Feb29144112@qcd.lanl.gov>
- <4hf485$1mgv@watnews1.watson.ibm.com>
- NNTP-Posting-Host: qcd.lanl.gov
- Mime-Version: 1.0
- Content-Type: text
- In-reply-to: ncohen@watson.ibm.com's message of 4 Mar 1996 16:03:17 GMT
-
- In article <4hf485$1mgv@watnews1.watson.ibm.com>
- ncohen@watson.ibm.com (Norman H. Cohen) writes:
-
- NHC: Famous last words! That's how we all started out! :-)
-
- Yup. I am replying because there is precisely one mistake in your
- argument. (Most of it I actually agree with). But, as I am replying, I
- also put forth some arguments.
-
- <snip>
- NHC: |> needed extensions. Things will change, and one should think of ANSI C
- NHC: |> as the only language that deserves to be called C anymore.
- NHC:
- NHC: You'd better tell that to Bill Gates.
-
- Most free software writers (including gnu) is shifting to my
- view :-) No argument, however: I predict that a few years from now
- nobody will bother about this particular issue.
-
- <snip>
- NHC: The Ada language was originally designed in response to a set of
- NHC: requirements promulgated by its intended users. The revision was driven
- NHC: by requirements that arose in the programming community, which provided
- NHC: plentiful input to a very open process.
-
- I agree that the language design team got input from the target
- community: it however did not have the `field testing' that C got in
- its pre-standard phase. That is what I meant.
-
- <snip>
- NHC: |> A minuscule community can have a well defined culture. A large and
- NHC: |> varied community cannot.
- NHC:
- NHC: I don't think the difference is in the size of the communities, but in
- NHC: the nature of the languages. Ada is designed specifically to facilitate
- NHC: disciplined software engineering. One cannot understand the proper use
- NHC: of Ada features without understanding data abstraction, encapsulation,
- NHC: and narrow, precisely defined interfaces. Therefore, these fundamental
- NHC: concepts are taught along with Ada. C can also be used in a disciplined
- NHC: way, of course, but the language design does not focus on this; rather,
- NHC: it focuses on ensuring microefficiency, it invites programming by side
- NHC: effect, and it glorifies the use of obscure notation.
-
- I agree that Ada probably does `encourage' safer practices, bu I do
- not think that is a major point: programming has only a little to do
- with the language. It is true that because many programmers from a
- generation of laxer software engineering practices still use C (and
- virtually none of them use Ada), as do a lot of people who both do not
- spend enough time in learning the language and cannot afford the
- runtime checks (a large fraction of the scientific community for
- example), many C programs are badly written.
-
- By the way, doesn't Ada require runtime checks? I thought it did, but
- I haven't looked at the language for a long time now: and have never
- programmed anything beyond `Hello world' in it. Most of the arguments
- in this post are incorrect if this assumption is false.
-
- I do not think that C encourages either microefficiency, or
- programming by side effect or that it glorifies obscure notation
- except for very well established idioms which every language develops
- over time. I agree it does not do much to deter these bad practices
- (that is part of `the spirit of C': if a user is mad, let his/her
- programs display the same insanity), but saying it encourages such
- constructs is going too far.
-
- NHC: |> NHC: rigorous validation suite to be approved for use on
- U.S. Department of
- NHC: |> NHC: Defense projects, and the requirement in the standard
- itself to reject
- NHC: |> NHC: certain forms of nonconformance at compile time, have led compiler
- NHC: |>
- NHC: |> So does the C standard.
- NHC: |>
- NHC: |> NHC: writers to implement the standard strictly and consistently.
- NHC:
- NHC: Incorrect. (And please stop cutting me off in mid-sentence! :-)) The C
- NHC: standard contains to requirement to detect any form of nonconformance at
- NHC: compile time. Section 1.7 of the standard states, "A _conforming_hosted_
- NHC: _implementation_ shall accept any strictly conforming program. A
- NHC: _conforming_freestanding_implementation_ shall accept any strictly
- NHC: conforming program in which the use of the features specified in the
- NHC: library section (Section 4) is confined to the contents of the standard
- NHC: <float.h>, <limits.h>, <stdarg.h>, and <stddef.h>." The converse ("A
- NHC: conforming implementation shall reject any program that is not strictly
- NHC: conforming.") is noticeably absent. Indeed, the paragraph continues, "A
- NHC: conforming implementation may have extensions (including additional
- NHC: library functions), provided they do not alter the behavior of any
- NHC: strictly conforming program."
-
- This is the only mistake in your post:
-
- The standard requires a diagnostic whenever any constraint or syntax
- rule is violated. (5.1.1.3). After diagnosing the error, it can do
- whatsoever it pleases.
-
- In fact, sometimes vendors deliberately want something to invoke
- `undefined' behaviour instead of violating a constraint, so that they
- can provide an extension that does not need a diagnostic. Some of them
- (e.g. $ in a macro name) even get accepted. But, by and large, a
- compiler cannot silently compile these category of errors.
-
- Errors which cannot be detected till run time in general (even if
- special cases can be) and a few occasional others lead to undefined
- behaviour. This is because the standard specifically did not think it
- necessary to put a run time penalty on any program: the implementation
- is allowed to put in checks, but is not required to.
-
- The standard also does not say that incorrect programs `are to be
- rejected'. It simply says that a diagnostic is required.
-
- Finally, some vendors get away thus: when you say `gcc' it
- compiles the GNU C language: which is distinct from C. Only when you
- say `gcc -pedantic' does it compile C code. As the standard cannot
- stop people from writing compilers for a language they do not even
- claim is the standard C, how can they stop this?
-
- NHC:
- NHC: |> No. What has lead to consistency is the small number of users with
- NHC: |> homogeneous needs.
- NHC:
- NHC: The needs of the Ada community are hardly homogeneous. Ada is
- NHC: implemented on a wide variety of processors, from supercomputers to
- NHC: embedded microprocessors and everything in between. It is used for
-
- But certainly not as wide as C? C is almost the first language to be
- implemented on every new chip that comes out: and I think that is
- because people `need' it. The Ada community is presumably a group of
- people who need to write code which will be reused for a long time,
- and probably on stable enough platforms that one does not have to work
- around machine/compiler deficiencies. It probably is also used by the
- community to whom safety is so important that it needs to be enforced
- by the language, instead of by programmer's habit and training; and by
- coding standards?
-
- Am I wrong? If I am right, I have little to say about those needs. I
- am a scientist by profession: to me it is important to get my results
- with the current technology, and not have to wait for future
- advances. Heck, my theory is more likely to be wrong than my
- programming; and I would rather write my code in a `manifestly
- correct' way and thoroughly check my code (and cross check it); than
- write in a language that will check every operation that I do. I
- typically code for 3 months human time, and run for 1 year's cpu time:
- I do not really care if that 3 months become four, but I can't afford
- the 1 year becoming 13 months!
-
- I have found that C can be used to write small understandable code
- with no overhead that I did not count on when I wrote my code. It is
- modular, portable and reusable. When even the small overhead is
- unacceptable (only in a tiny fraction of the code of course), I drop
- down to assembly, and thus give up on portability and
- reusability. That is one reason why I avoid C++ for example: the
- hidden costs are often unacceptable; forcing me into non-portable
- constructs more often. That is why I sometimes switch to Fortran:
- Fortran standard guarantees far less than the C standard, and hence
- the compilers can be much more aggressive without violating the
- standard.
-
- All of this is a tradeoff between usability and efficiency. In the
- kind of job I do, C (or Fortran or C++ according to exactly who you
- talk to) is the compromise. I do not deny that depending on the
- relative importance of the various factors, the compromise could be
- different in other fields.
-
- NHC: applications as varied as finance, command and control, systems
- NHC: programming, computer-aided design, VLSI design, medical instrumentation,
- NHC: and virtual reality, among others.
-
- And do people use it for supercomputing? That is a non-rhetorical
- question: I really do not think that in most of the stuff I do I would
- like the run time checks (I do indeed code the really time intensive
- stuff in pseudo-assembly, the rest in statically tested C or
- Fortran. I run mainly on the CM5, and do not think that an Ada port
- exists for this machine). Or, can one switch off the checks in Ada?
-
- If people do use this in real large scale computation, how much of the
- typical code is in `unsafe' modules?
-
- Cheers
- Tanmoy
- --
- tanmoy@qcd.lanl.gov(128.165.23.46) DECNET: BETA::"tanmoy@lanl.gov"(1.218=1242)
- Tanmoy Bhattacharya O:T-8(MS B285)LANL,NM87545 H:#9,3000,Trinity Drive,NM87544
- Others see <gopher://yaleinfo.yale.edu:7700/00/Internet-People/internet-mail>,
- <http://alpha.acast.nova.edu/cgi-bin/inmgq.pl>or<ftp://csd4.csd.uwm.edu/pub/
- internetwork-mail-guide>. -- <http://nqcd.lanl.gov/people/tanmoy/tanmoy.html>
- fax: 1 (505) 665 3003 voice: 1 (505) 665 4733 [ Home: 1 (505) 662 5596 ]
-